#pragma once

#include <memory>
#include <list>
#include "BattleShip.h"

typedef std::list<unsigned int> ListOfEncode;
typedef std::set<unsigned int> SetOfEncode;

class PartOfBattle 
{
private:
	int m_table [MAX_H/2][MAX_V/2];
	int m_count [MAX_H/2][MAX_V/2];
	bool m_existShip;
	bool m_transformX,m_transformY;
	ListOfEncode m_posibility;
	void RefreshCount(ListOfEncode newPosibility);
	bool m_lock;
	void Lock();
	void Unlock();
public:
	PartOfBattle(bool _transformX, bool _transformY);
	~PartOfBattle();
	bool IsContain(Point p);
	void SetValue(Point p, bool contain);
	static bool GetValue(unsigned int _encode, int posX, int posY);
	static bool GetValue(unsigned int _encode, Ship::TypeOfShip type);
	void RemovePosibility(ListOfEncode listOfEncode);
	void InsertPosibility(unsigned int _encode);
	void InsertPosibility(ListOfEncode _setOfEncode);
	int GetCount(Point p);
	void SetCount(int count[5][5]);
	int GetWeight();
	bool IsUnkown(Point p);
	bool IsContainShip(ShipPtr ship);
	void RemoveShipType(Ship::TypeOfShip type);
};

#if (_MSC_VER == 1700)  
typedef std::shared_ptr<PartOfBattle> PartOfBattlePtr;
#else
typedef boost::shared_ptr<PartOfBattle> PartOfBattlePtr;
#endif